package org.team4.dao.meta;

import java.util.List;

import org.hibernate.SessionFactory;
import org.team4.constants.SQLConstant;
import org.team4.dao.GenericDAO;
import org.team4.domain.RoleUsers;
import org.team4.exception.CRUDException;

import org.team4.dao.meta.RoleUsersDAO;


public class RoleUsersDAO extends GenericDAO<RoleUsers> {

	private static final long serialVersionUID = 622832120994917754L;
	private static RoleUsersDAO instance;
	
	public static RoleUsersDAO getInstance(SessionFactory sessionFactory) {
        if(instance == null) {
            instance =  new RoleUsersDAO(sessionFactory);
        }
        return instance;
    }
	
    /**
     * 构造函数
     * 
     * @param sessionFactory
     */
    private RoleUsersDAO(SessionFactory sessionFactory) {
        super(sessionFactory, RoleUsers.class);
    }
    
    /**
     * 根据用户ID查找用户权限
     * 
     * @param usersId
     * @return
     * @throws CRUDException
     */
    public List<RoleUsers> findUsersRoleByUsers(String usersId) throws CRUDException {
        return this.find(SQLConstant.ROLEUSERS_BY_USERS_HQL, usersId);
    }
}